<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../css/register.css">
<title>学生注册</title>
</head>
<script type="text/javascript">
function checkPwd()
{
	var pwd1 = document.getElementById("pwd1");
	var pwd2 = document.getElementById("pwd2");
	var PwdInfo = document.getElementById("PwdInfo");
	if(pwd1.value != pwd2.value)
		PwdInfo.innerHTML = "两次密码不一致请重新输入";
	else if(pwd1.value.length == 0)
		PwdInfo.innerHTML = "密码不能为空";
	else
		PwdInfo.innerHTML = "";
}
function addCheck(){
	var pwd1 = document.getElementById("pwd1");
	var pwd2 = document.getElementById("pwd2");
	var PwdInfo = document.getElementById("PwdInfo");
	if(pwd1.value != pwd2.value)
		PwdInfo.innerHTML = "两次密码不一致请重新输入";
	else if(pwd1.value.length == 0)
		PwdInfo.innerHTML = "密码不能为空";
	else
	{
		PwdInfo.innerHTML = "";
		form1.action="studentadd.jsp";
		form1.submit();
	}
}
</script>
<body>
<%
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/classfee", "root", "1234");
	Statement stmt = con.createStatement();
	ResultSet rst = stmt.executeQuery("SELECT * FROM  tb_class");
%>
<div id="maincontent">
<div id="regHead">
<a href="../HomePage.html" id="backhome">首页</a>
<p id="head1">学生注册<p>
</div>
<div id="textArea">
<form  method ="post" name="form1">
<ul class="nopoint">
<li><label for="stuId">学号：</label></li>
<li><input type="text"  name="stuId" id="stuId"></li>
<li><label for="stuName">名字：</label></li>
<li><input type="text"  name="stuName" id="stuName"></li>
<li><label for="classId">所属班级：</label></li>
<li><select name="classId" id="classId"><%while(rst.next()){ %><option value=<%out.println(rst.getInt("classId")); %>><%out.println(rst.getString("className")); %></option><%} %></select></li>
<li><label for="stuSex">性别：</label></li>
<li><select  name="stuSex" id="stuSex"><option>男</option><option>女</option></select></li>
<li><label for="pwd1">密码：</label></li>
<li><input type="password" name="stuPwd" id="pwd1"></li>
<li><label for="pwd2">确认密码：</label><label id="PwdInfo" style="color:red"></label></li>
<li><input type="password" name="stuPwd2" id="pwd2" onblur="checkPwd()"></li>
<li id="libutton"><input type="button" value="添  加" onclick="addCheck()"></li>
</ul>
</form>
</div>
</div>
</body>
</html>